package cn.chint.manage.controller;

import cn.chint.bo.Reviewbo;
import cn.chint.bo.RivewPages;
import cn.chint.manage.dao.ReviewerDao;
import cn.chint.manage.service.ReviewerServe;
import cn.chint.po.Review;
import cn.chint.po.User;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class ReviewerController {
    @Autowired
    ReviewerServe reviewerServe;
    @Autowired
    ReviewerDao reviewerDao;

    @ResponseBody
    @RequestMapping(value = "review", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Map sel(ModelMap modelMap, HttpServletRequest request, HttpServletResponse response){
        String name_wx = request.getParameter("name_wx");
        int flag  = reviewerServe.inst(name_wx);
        Map<String,Object> map = new HashMap<String, Object>();
        map.put("code",0);
        map.put("msg","");
        map.put("data",flag);
      return map;
    }


    @RequestMapping(value = "reviewSel", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public Map ins(){
        List<Review> reviewList = reviewerDao.sel();
        Map<String,Object> map = new HashMap<String, Object>();
        map.put("code",0);
        map.put("msg","");
        map.put("data",reviewList);
        return map;
    }
}
